package com.julius.design.pattern.adapter;

/**
 * <p>
 *      适配器类
 * </p>
 */
public class MediaAdapter {

    private NewMediaPlayer newMediaPlayer;


    public MediaAdapter(String newName) {

        if ("mp5".equalsIgnoreCase(newName)) {
            newMediaPlayer = new Mp5Player();
        }
        if ("mp4".equalsIgnoreCase(newName)) {
            newMediaPlayer = new Mp4Player();
        }
    }

    public void play(String name) {

        if ("mp4".equalsIgnoreCase(name) ) {
            newMediaPlayer.playMp4();
        }
        if ("mp5".equalsIgnoreCase(name)) {
            newMediaPlayer.playMp5();
        }

    }


}
